<template>
	<view class="main">
		<view>
			<u-form>
				<u-form-item label-width="120" label="选择地区">
					<u-input v-model="areaSelected" type="select" :border="true" @click="areaListshow = true"/>
				</u-form-item>
			</u-form>
			<u-button type="primary" @click="faxian()">发现老乡</u-button>
			<u-select v-model="areaListshow" mode="mutil-column-auto" :list="areaList" @confirm="confirm"></u-select>
		</view>
		<view class="showArea">
			<u-card :title='item.name' :sub-title='item.sex' v-for='item in listinfo'>
				<view class="" slot="body">
					<view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
						<view class="u-body-item-title u-line-2">联系方式：{{item.telephone}}</view>
					</view>
				</view>
			</u-card>
		</view>
		<view class="showArea2" v-if="areaShow">
			暂未发现您的老乡！
		</view>
	</view>
</template>

<script>
	export default{
		components:{
			
		},
		data(){
			return{
				areaListshow:false,
				areaSelected:'',
				areaShow:false,
				listinfo:[],
				areaList:[
					{value:1,label:'河南',children:[
						{value:9999,label:'',children:[{value:9998,label:''}]},
						{value:11,label:'洛阳',children:[{value:9989,label:''},{value:111,label:'洛龙区'},{value:112,label:'老城区'}]},
						{value:12,label:'新乡',children:[{value:121,label:'一区'},{value:122,label:'八区区'}]},
						{value:13,label:'南阳',children:[{value:131,label:'四区区'},{value:132,label:'三区区'}]},
						{value:14,label:'平顶山',children:[{value:141,label:'五区区'},{value:142,label:'七区区'}]},
						]},
					{value:2,label:'新疆',children:[
						{value:9997,label:'',children:[{value:9996,label:''}]},
						{value:21,label:'乌鲁木齐',children:[{value:211,label:'天山区'},{value:212,label:'新区'}]}]},
					{value:3,label:'河北',children:[
						{value:31,label:'石家庄',children:[{value:311,label:'一区'},{value:312,label:'二区'}]}]},
					{value:4,label:'甘肃',children:[
						{value:41,label:'兰州',children:[{value:411,label:'一区'},{value:412,label:'二区'}]}]}
				]
			}
		},
		onShow() {
			
		},
		methods:{
			confirm(e){
				this.areaSelected=e[0].label+e[1].label+e[2].label
			},
			faxian(){
				var _this=this
				if(_this.areaSelected==''){
					uni.showToast({
						title:'请选择查询条件',
						icon:'none'
					})
				}else{
					var url='http://taruinfo.work:8088/newborn/likeLeftNewbornByLists?current=1&province='+this.areaSelected+'&size=10';
					uni.request({
						url:url,
						method:'get',
						success:function(res){
							// console.log(res.data)
								_this.listinfo=res.data.data.records
								if(_this.listinfo.length==0){
									_this.areaShow=true
								}else{
									_this.areaShow=false
								}
								
						},
						fail:function(res){
							uni.showToast({
								title:res.data.message,
								icon:'none'
							})
						}
					})
				}
			}
		}
	}
</script>

<style scoped>
	.main{
		margin-left: 15rpx;
		margin-right:15rpx;
	}
	.showArea2{
		text-align: center;
		margin-top: 280rpx;
	}
</style>
